@extends('admin::layouts.master')
@section('title') 门店列表 @endsection
@section('tab')
    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <ul class="layui-tab-title">
                        <li data-type="" @if($data['cate']=='') class="layui-this" @endif>全部</li>
                        <li data-type="1" @if($data['cate']==1) class="layui-this" @endif>检测机构</li>
                        <li data-type="2" @if($data['cate']==2) class="layui-this" @endif>维修店</li>
                        <li data-type="3" @if($data['cate']==3) class="layui-this" @endif>道路救援</li>
                    </ul>

                    <div class="layui-card-body" style="border-bottom: none;">
                        <form class="layui-form layui-col-space5">
                            <input type="hidden" name="cate" value="{{$data['cate']}}">
                            <div class="layui-input-inline layui-show-xs-block">
                                <input type="text" name="name" placeholder="门店名称" value="{{$data['name']}}"
                                       autocomplete="off" class="layui-input">
                            </div>
                            <div class="layui-input-inline layui-show-xs-block">
                                <input type="text" name="phone" placeholder="联系电话" value="{{$data['phone']}}"
                                       autocomplete="off" class="layui-input">
                            </div>

                            <div class="layui-input-inline layui-show-xs-block">
                                <select name="province" lay-filter="province">
                                    <option value="">请选择省份</option>
                                    @foreach($list['province'] as $p => $pr)
                                        <option value="{{$pr['province']}}" @if($data['province']==$pr['province']) selected @endif >{{$pr['province_name']['name']}}</option>
                                    @endforeach
                                </select>
                            </div>

                            <div class="layui-input-inline layui-show-xs-block">
                                <select name="city" lay-filter="city" id="city">
                                    <option value="">请选择城市</option>
                                    @foreach($list['city'] as $c => $ci)
                                        <option value="{{$c}}" @if($data['city']==$c) selected @endif >{{$ci}}</option>
                                    @endforeach
                                </select>
                            </div>

                            <div class="layui-input-inline layui-show-xs-block">
                                <select name="area" lay-filter="area" id="area">
                                    <option value="">请选择区域
                                    @foreach($list['area'] as $a => $ar)
                                        <option value="{{$a}}" @if($data['area']==$a) selected @endif>{{$ar}}</option>
                                    @endforeach
                                </select>
                            </div>

                            <div class="layui-input-inline layui-show-xs-block">
                                <button class="layui-btn" lay-submit="" lay-filter="sreach">
                                    <i class="layui-icon">&#xe615;</i>
                                </button>
                                <button class="layui-btn" onclick="location.reload()">
                                    <i class="layui-icon layui-icon-refresh"></i>
                                </button>
                                <a class="layui-btn layui-btn-normal" onclick="xadmin.open('添加道路救援商铺','{{route("admin_shop_road_help_add_page")}}',800,600)"><i class="layui-icon"></i>添加</a>
                            </div>
                        </form>
                        {{--<div class="layui-card-body">
                            <button class="layui-btn layui-btn-normal" onclick="xadmin.open('添加道路救援商铺','{{route("admin_shop_road_help_add_page")}}',800,600)"><i class="layui-icon"></i>添加道路救援商铺</button>
                        </div>--}}
                    </div>
                    <div class="layui-card-body layui_overflow_y ">
                        <table class="layui-table layui-form">
                            <thead>
                            <tr>
                                <th width="2%">编号</th>
                                <th width="20%">店铺名称</th>
                                <th width="3%">类型</th>
                                <th width="8%">联系方式</th>
                                <th width="10%">省、市、区</th>
                                <th width="5%">是否直营</th>
                                <th width="10%">创建时间</th>
                                <th width="20%">操作</th>
                            </tr>
                            </thead>
                            <tbody>

                            @foreach($list['data'] as $key=>$value)
                                <tr>
                                    <td>{{$value['id']}}</td>
                                    <td>{{$value['name']}}</td>
                                    <td>
                                        @switch($value['cate'])
                                            @case(1)
                                            检测机构
                                            @break

                                            @case(2)
                                            维修店
                                            @break

                                            @case(3)
                                            道路救援
                                            @break
                                            @default
                                            未知
                                        @endswitch
                                    </td>
                                    <td>{{$value['phone']}}</td>
                                    <td>{{$value['area_name']['mername']}}</td>
                                    <td>
                                        @if($value['cate'] == 2)
                                        <input type="checkbox" name="switch" data_attr='{"id":"{{$value['id']}}","field_name":"shop_type","url":"{{route("admin_shop_changeType")}}"}' lay-text="是|否" lay-filter="change_state" @if($value['shop_type'] == 1) checked @endif lay-skin="switch">
                                        @else
                                            加盟店
                                        @endif
                                    </td>
                                    <td>{{$value['created_at']}}</td>
                                    <td class="td-manage">

                                        @switch($value['cate'])
                                            @case(1)
                                            <button class="layui-btn layui-btn-xs" onclick="xadmin.open('检测站-店铺详情-{{$value['name']}}','{{route("admin_shop_detail",['id'=>$value['id']])}}')" href="javascript:;" >店铺详情</button>
                                            <button class="layui-btn layui-btn-xs layui-bg-green" onclick="xadmin.open('检测站-开放日期-{{$value['name']}}','{{route("admin_shop_cp_appointment_date",['id'=>$value['id']])}}')" href="javascript:;" >开放日期</button>
{{--                                            <button class="layui-btn layui-btn-xs layui-bg-orange" onclick="xadmin.open('检测站-规格-{{$value['name']}}','{{route("admin_shop_cp_service_specs",['id'=>$value['id']])}}')" href="javascript:;" >规格</button>--}}
{{--                                            <button class="layui-btn layui-btn-xs layui-bg-red" onclick="xadmin.open('检测站-价目表-{{$value['name']}}','{{route("admin_shop_cp_service_product",['id'=>$value['id']])}}')" href="javascript:;" >价目表</button>--}}
{{--                                            <button class="layui-btn layui-btn-xs layui-bg-cyan" onclick="xadmin.open('检测站-年检预约单-{{$value['name']}}','{{route("admin_shop_cp_appointment_order",['id'=>$value['id']])}}')" href="javascript:;" >年检预约单</button>--}}
                                            @break

                                            @case(2)
                                            <button class="layui-btn layui-btn-xs" onclick="xadmin.open('维修店-店铺详情-{{$value['name']}}','{{route("admin_shop_detail",['id'=>$value['id']])}}')" href="javascript:;" >店铺详情</button>
                                            <button class="layui-btn layui-btn-xs layui-bg-green" onclick="xadmin.open('维修店-商品列表-{{$value['name']}}','{{route("admin_shop_goods_list",['id'=>$value['id']])}}')" href="javascript:;" >商品列表</button>
                                            <button class="layui-btn layui-btn-xs layui-bg-orange" onclick="xadmin.open('检测站-服务商品列表-{{$value['name']}}','{{route("admin_shop_repair_list",['id'=>$value['id']])}}')" href="javascript:;" >服务商品列表</button>

                                            @break

                                            @case(3)

                                            @break
                                            @default

                                        @endswitch
                                        @if($value['admin_id'] == 1)
                                            <button class="layui-btn layui-btn-xs" onclick="xadmin.open('编辑平台店铺','{{route("admin_author_repairStoreDetail")}}')" href="javascript:;" >编辑</button>
                                        @endif
                                    </td>
                                </tr>
                            @endforeach
                            @if(empty($list['data']))
                                <td colspan="66" align="center">暂无数据</td>
                            @endif
                            </tbody>
                        </table>
                    </div>
                    <div class="layui-card-body ">
                        <div class="page">
                            {{$list['page_link']}}
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

@endsection


@section('tab_js')
    <script>
        $(document).on('click', '.layui-tab-title li', function () {
            var cate = $(this).attr('data-type');
            var data = '?cate='+cate;
            location_redirect('admin-shop-index'+data);
        });
        layui.use('form', function(){
            var form = layui.form;
            //监听指定开关-修改状态
            form.on('switch(change_state)',function(){
                change_state(this);
            });

            form.render();
        });
    </script>
@endsection


